import { Column, Entity, OneToMany } from 'typeorm';
import { BaseEntity } from '../../../common/entities/base.entity';
import { SiteCategoryMap } from './site-category-map.entity';

export enum MasterCategoryStatus {
  DISABLED = 0,
  ACTIVE = 1,
}

@Entity('master_categories')
export class MasterCategory extends BaseEntity {
  @Column({ type: 'varchar', length: 50, comment: '母分类名称' })
  name: string;

  @Column({ type: 'varchar', length: 200, comment: '推荐关键词' })
  keywords: string;

  @Column({
    type: 'tinyint',
    default: MasterCategoryStatus.ACTIVE,
    comment: '状态: 0-禁用 1-启用',
  })
  status: MasterCategoryStatus;

  @Column({ type: 'text', nullable: true, comment: '分类描述' })
  description?: string;

  @Column({ type: 'int', default: 0, comment: '排序权重' })
  sortOrder: number;

  // 关联关系
  @OneToMany(() => SiteCategoryMap, (map) => map.masterCategory)
  siteMappings: SiteCategoryMap[];
}